package cz.fit.vutbr.pis2012.augeaswh.control.ekonom.supplier;

import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;

import cz.fit.vutbr.pis2012.augeaswh.managers.SupplierManager;
import cz.fit.vutbr.pis2012.augeaswh.persistence.Supplier;

@ManagedBean
@ViewScoped
public class SupplierConfirmDeleteDialogBean {
	@EJB
	private SupplierManager sm;	
	private Supplier supplier;
	
	public String getTitle() {
		return "Deleting supplier";
	}
	
	public String getQuestion() {
		if(this.supplier==null)
			return "";
		return "Are you sure you want to delete the supplier "+supplier.getName()+"?"; 
	}
	
	public void submit() {
		if(this.supplier!=null) {
			sm.delete(this.supplier);
			this.supplier=null;
		}
	}

	public Supplier getSupplier() {
		return supplier;
	}

	public void setSupplier(Supplier supplier) {
		this.supplier = supplier;
	}
}
